from sanic import Blueprint, Sanic, json

from app.core.entity import ApiResult
from app.entity.user import User
from app.utils.Aliyun.AliyunSmsUtils import AliyunSmsUtils
from app.utils.CommonUtils import tupleListToDict
from app.utils.FileUtils import FileUtils

from sqlalchemy import Result, text

from alibabacloud_tea_openapi import models

bp=Blueprint("test",url_prefix="/test")

app=Sanic.get_app()

@bp.route('/index',methods=['GET'])
async def test(request):
    connection= User().getEngine().raw_connection()
    cursor_obj=connection.cursor()
    cursor_obj.callproc("prod_get_project_bill",[569972498411590])
    result1= tupleListToDict(cursor_obj.fetchall(),'id,name,created_at,sum_price,max_price') 
    cursor_obj.nextset()
    result2=tupleListToDict(cursor_obj.fetchall(),'total_people')
    cursor_obj.nextset()
    result3=tupleListToDict(cursor_obj.fetchall(),'payer_desc,price')
    cursor_obj.nextset()
    result4=tupleListToDict(cursor_obj.fetchall(),'price,title')
    cursor_obj.close()
    return json({
        "result1":result1,
        "result2":result2,
        "result3":result3,
        "result4":result4
    })
    